package com.mrroman.linksender.gui.actions;

import com.mrroman.linksender.filesender.ServerManager;
import java.awt.event.ActionEvent;
import java.util.ResourceBundle;

import javax.swing.AbstractAction;

import com.mrroman.linksender.ioc.In;
import com.mrroman.linksender.ioc.Init;
import com.mrroman.linksender.ioc.Locales;
import com.mrroman.linksender.ioc.Name;
import com.mrroman.linksender.sender.MessagePoint;
import com.mrroman.linksender.sender.PrivateMessagePoint;

@Name("actions.ExitAction")
public class ExitAction extends AbstractAction {

	@In
	private MessagePoint msgPoint;

    @In
    private PrivateMessagePoint privPoint;

    @In
    private ServerManager serverManager;
	
	@Locales
	ResourceBundle messages;
	
	@Init
	public void init() {
		putValue(NAME, messages.getString("exit"));
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
        serverManager.stopServer();
        privPoint.stopServer();
		msgPoint.stopServer();
		System.exit(0);
	}
	
}
